from app.extension.database.sqlalchemy import sqla_db as db
from datetime import datetime
from .base_model import BaseModel


class OrderModel(db.Model, BaseModel):
    """订单模型"""

    __tablename__ = 'tb_order'
    id = db.Column(db.Integer, primary_key=True, comment='主键')
    mobile = db.Column(db.String(15), comment='电话号码')
    name = db.Column(db.String(80), comment='联系人姓名')

    province = db.Column(db.String(80))
    city = db.Column(db.String(80))
    country = db.Column(db.String(80))
    detail = db.Column(db.String(200), comment='完整的地址')
    user_id = db.Column(db.Integer, comment='关联的用户ID')

    order_no = db.Column(db.String(50), unique=True, nullable=False, comment='订单编号', )
    create_time = db.Column(db.DateTime, default=datetime.now)
    delete_time = db.Column(db.DateTime)
    total_price = db.Column(db.Integer, comment='订单总价格 分')
    status = db.Column(db.Integer, comment='商品状态 1没有支付 2已将支付')
    snap_name = db.Column(db.String(50), comment='订单的商品名')
    snap_address = db.Column(db.String(255), comment='订单的地址')
    snap_img_url = db.Column(db.String(255), comment='订单的缩略图')
    total_count = db.Column(db.Intger, comment='商品的总数量')
    prepay_id = db.Column(db.String(255), comment='订单微信支付的预订单（用于发送模板信息）')
